﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace SilverTile.ExtensionMethods
{
    public static class ColorExtentionMethods
    {
        public static Int32 ToInt32(this Color color)
        {
            // Stolen from Jeff Wilcox: http://www.jeff.wilcox.name/2009/09/silverlight-toargb/
            int argb = color.A << 24;
            argb += color.R << 16;
            argb += color.G << 8;
            argb += color.B;

            return argb;
        }

        public static Color ToColor(this Int32 color)
        {

            byte a = (byte)((color >> 24) & 0xFF);
            byte r = (byte)((color >> 16) & 0xFF);
            byte g = (byte)((color >> 8) & 0xFF);
            byte b = (byte)(color & 0xFF);

            return Color.FromArgb(a, r, g, b);
        }
    }
}
